CSharpTest.Net
DebugSetValidateOnCheckpoint Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : DebugSetValidateOnCheckpoint Method

validate

Glossary Item Box

Sets a boolean condition that will validate the state of the entire btree after every operation.

Syntax

Visual Basic (Declaration) 
Public Sub DebugSetValidateOnCheckpoint( _
   ByVal validate As Boolean _
) 
C# 
public void DebugSetValidateOnCheckpoint( 
   bool validate
)

Parameters

validate

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C#Copy Code
int iterations = 5;
int limit = 255;

using (BPlusTree<int, string> data = Create(Options))
{
    data.EnableCount();

    List<int> numbers = new List<int>();
    while (iterations-- > 0)
    {
        data.Clear();
        numbers.Clear();
        data.DebugSetValidateOnCheckpoint(true);

        for (int i = 0; i < limit; i++)
        {
            int id = Random.Next(limit);
            if (!numbers.Contains(id))
            {
                numbers.Add(id);
                data.Add(id, "V" + id);
            }
        }

        Assert.AreEqual(numbers.Count, data.Count);

        foreach (int number in numbers)
            Assert.IsTrue(data.Remove(number));

        Assert.AreEqual(0, data.Count);
    }
}
VB.NETCopy Code
Dim iterations As Integer = 5
Dim limit As Integer = 255

Using data As BPlusTree(Of Integer, String) = Create(Options)
    data.EnableCount()

    Dim numbers As New List(Of Integer)()
    While System.Math.Max(System.Threading.Interlocked.Decrement(iterations),iterations + 1) > 0
        data.Clear()
        numbers.Clear()
        data.DebugSetValidateOnCheckpoint(True)

        Dim i As Integer = 0
        While i < limit
            Dim id As Integer = Random.[Next](limit)
            If Not numbers.Contains(id) Then
                numbers.Add(id)
                data.Add(id, "V" + id)
            End If
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.AreEqual(numbers.Count, data.Count)

        For Each number As Integer In numbers
            Assert.IsTrue(data.Remove(number))
        Next

        Assert.AreEqual(0, data.Count)
    End While
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys